<?php
/**
 * licenses : MIT
 * creatTime: 2020/5/13
 * author : weblinuxgame
 * filename: MessageEnum.php
 */

namespace App\Core\Utils;

use App\Core\Enums\MsgEnum;

/**
 * 业务码类
 * Class Message
 * @package App\Core\Enums
 */
class Message implements MsgEnum
{

    /**
     * 通过业务码获取消息
     * @param int $code # 业务码
     * @param string $local #语种 @todo
     * @return string
     */
    public static function message(int $code, $local = "zh"): string
    {
        if ($local != "zh") {
            return self::UnSupportServiceMsg;
        }
        $msg = self::MsgKvMap[$code];
        if (empty($msg) || $msg == "") {
            return self::UndefinedError;
        }
        return $msg;
    }

    public static function code(string $msg, $local = "zh"): int
    {
        if ($local != "zh") {
            return self::UnSupportService;
        }
        foreach (self::MsgKvMap as $code => $message) {
            if ($msg == $message) {
                return $code;
            }
        }
        return self::UnSupportService;
    }

    public static function lang()
    {
        // @todo
    }

}
